<ui:composition
		xmlns="http://www.w3.org/1999/xhtml"
		xmlns:h="http://java.sun.com/jsf/html"
		xmlns:f="http://java.sun.com/jsf/core"
		xmlns:a4j="http://richfaces.org/a4j"
		xmlns:rich="http://richfaces.org/rich"
		xmlns:ui="http://java.sun.com/jsf/facelets"
		xmlns:itdep="http://itdep.bsuir.by/jsf"
		>
	<f:loadBundle basename="bundle.address" var="addressBundle"/>
	<f:loadBundle basename="bundle.person" var="personBundle"/>
	<h:panelGroup id="#{idPrefix}AddrEditPanel">
		<h:panelGrid id="#{idPrefix}AddrPanelGrid" columns="2" width="380px">

			<h:outputText value="#{studentBundle.accomodationType}" rendered="#{accomod}"
						  styleClass="requiredField"/>
			<itdep:entitySelectMenu value="#{studentBean.record.accomodationType}"
									entityType="accomodation-type"
									id="#{idPrefix}AccomodationType"
									format="{i18n.description}" rendered="#{!accomod}" required="true"
									styleClass="sizeCopmonent">
			</itdep:entitySelectMenu>

			<h:outputText value="#{personBundle.addressType}" styleClass="requiredField" rendered="#{addrType}"/>
			<itdep:entitySelectMenu value="#{address.addressType}" entityType="address-type" format="{i18n.fullName}"
									rendered="#{!addrType}" anyValue="true" styleClass="sizeCopmonent">
				<a4j:support event="onchange" reRender="#{idPrefix}AddrEditPanel" ajaxSingle="true"/>
			</itdep:entitySelectMenu>

			<h:outputText value="#{addressBundle.country}" styleClass="requiredField"/>
			<itdep:entitySelectMenu value="#{addrBean.filter.country}"
									entityType="country"
									format="{name}"
									id="#{idPrefix}Country"
									disabled="#{empty address.addressType and addrType}" anyValue="true"
									styleClass="sizeCopmonent">
				<a4j:support event="onchange" reRender="#{idPrefix}AddrEditPanel"/>
			</itdep:entitySelectMenu>


			<h:outputText value="#{addressBundle.city}" styleClass="requiredField"/>
			<h:panelGroup>
				<h:inputText value="#{addrBean.filter.city.name}" disabled="#{empty addrBean.filter.country}"
							 id="#{idPrefix}CityInput" styleClass="sizeCopmonent"/>
				<rich:suggestionbox for="#{idPrefix}CityInput" id="#{idPrefix}CitySuggestion"
									height="100" width="500" minChars="2"
									suggestionAction="#{addrBean.suggest}" var="result"
									fetchValue="#{result.name}"
									nothingLabel="#{addressBundle.nothingFound}">
					<h:column>
						<h:outputText value="#{result.name}, "/>
						<itdep:entityOutput value="#{result.cityType}" format="{i18n.shortName}"
											locale="#{translationBean.locale}"/>
					</h:column>
					<h:column>
						<h:outputText value="#{result.settlement.name} / "/>
						<h:outputText value="#{result.settlement.district.name}"/>
					</h:column>


					<a4j:support event="onselect" reRender="#{idPrefix}AddrEditPanel" ajaxSingle="true">
						<f:setPropertyActionListener value="#{result}" target="#{addrBean.filter.city}"/>
					</a4j:support>
				</rich:suggestionbox>
			</h:panelGroup>


			<h:outputText value="#{addressBundle.street}" styleClass="requiredField"/>
			<itdep:entitySelectMenu value="#{address.street}" entityType="street" format="{name}"
									filter="#{addrBean.filter}" disabled="#{empty addrBean.filter.city}"
									anyValue="true" styleClass="sizeCopmonent">
				<a4j:support event="onchange" reRender="#{idPrefix}AddrEditPanel" ajaxSingle="true"/>
			</itdep:entitySelectMenu>

			<h:outputText value="#{addressBundle.buildingNumber}" styleClass="requiredField"/>
			<h:panelGroup>
				<h:inputText id="#{idPrefix}BuildingNumber" value="#{address.buildingNumber}"
							 disabled="#{empty address.street}" required="true" styleClass="sizeCopmonent"
							 maxlength="20"/>
				<itdep:errorMessage for="#{idPrefix}BuildingNumber"/>
			</h:panelGroup>

			<h:outputText value="#{addressBundle.flatNumber}"/>
			<h:inputText value="#{address.flatNumber}" disabled="#{empty address.street}" styleClass="sizeCopmonent"
						 maxlength="20"/>
		</h:panelGrid>

		<ui:insert name="AccomodationType"/>
	</h:panelGroup>

</ui:composition>
